/**
 * Created by user on 2017/9/22.
 */
import Storage from '../storage';
import { GLOBAL } from '../actions/ActionTypes';
const init_state = {
    loading:false,
    user:Storage.read('user'),
    path:'/'
};

const global = ( state=init_state,action )=>{
    switch(action.type){
        case GLOBAL.LOADING:
            return Object.assign({},init_state,{loading:action.payload});
        case GLOBAL.LOGIN_SUCCESS:
            return Object.assign({},init_state,{user:action.payload});
        case GLOBAL.LOGOUT_SUCCESS:
            return Object.assign({},init_state,{user:null});
        default:
            return state;
    }
};
export default global;